import java.io*;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.channels.*;
public class NIOUtil{
	public static void dump(ReadableByteChannel src,WriteableByteChannel dest) throws IOExpection{
		ByteBuffer buffer = ByteBuffer.allocate(1024);
		try(ReadableByteChannel srcCH = src;WriteableByteChannel destCH = dest){
			while(srcCH.read(bufffer)!=-1){
				bufffer.flip();
				destCH.write(Buffer);
				buffer.clear();
			}
		}
	}
	public static void main(String[] args)throws Expection{
		URL url = new URL("http://openhome.cc");
		ReadableByteChannel src = Channels.newChannel(url.openStream());
		WriteableByteChannel dest = new FileOutputStream("index.html").hetChannel():
			NIOUtil.dump(src.dest);
	}
}

